(function() {
    var scripts = document.getElementsByTagName('script');
    var i = 0;
    //如果页面已经使用renren forward 则不再添加
    for (i; i < scripts.length; i++) {
        if ('http://widget.renren.com/js/forward.js' == scripts[i].src) {
            return false;
        }
    }
    var head = document.getElementsByTagName('head')[0];
    //获取config.js绝对路径
    var configPath = chrome.extension.getURL("js/config.js");
    //配置config.js的script标签
    var config = document.createElement('script');
    config.type = 'text/javascript';
    config.src = configPath;
    //配置forward.js的script标签
    var renren = document.createElement('script');
    renren.type = 'text/javascript';
    renren.src = "http://widget.renren.com/js/forward.js";
    renren.async = "true"
    //添加两个js文件到head标签中
    head.appendChild(config);
    head.appendChild(renren);
})()